Repository navigation
[material_ui] Paint Scaffold persistent bottom sheet background color behind the keyboard - #13242
Conversation
…d the keyboard Ports flutter/flutter#186365 to material_ui. With a persistent bottom sheet (Scaffold.bottomSheet or ScaffoldState.showBottomSheet) and resizeToAvoidBottomInset: true, the sheet is lifted above the keyboard and the Scaffold's own Material is what sits behind the keyboard. On iOS 26 the keyboard is translucent, so the scaffold color shows through under the sheet instead of the sheet's color. _ScaffoldLayout now extends the persistent sheet's slot by the part of the keyboard inset not already covered by the bottom bars, while still reporting the content-only height so FAB and SnackBar geometry are unchanged. The inset reaches the pre-built sheet widgets through _BottomSheetBoxConstraints and a LayoutBuilder, and _StandardBottomSheet pads its content inside the BottomSheet's Material by that amount (growing the sheet's constraints to match), so the sheet's surface continues behind the keyboard. Fixes the framework-owned part of flutter/flutter#179482.
There was a problem hiding this comment.
Code Review
This pull request modifies the Scaffold persistent bottom sheet to extend its Material behind the software keyboard when resizeToAvoidBottomInset is true, allowing translucent keyboards to show the sheet's surface. It introduces _BottomSheetBoxConstraints and _BottomSheetKeyboardInset to pass the keyboard inset to the bottom sheet, updates the layout and padding logic, and adds corresponding tests. Feedback suggests using a safe type check instead of a direct cast on constraints to avoid potential runtime TypeErrors during dry layout or intrinsic height calculations.
| final Widget stack = LayoutBuilder( | ||
| builder: (BuildContext context, BoxConstraints constraints) { | ||
| return _BottomSheetKeyboardInset( | ||
| inset: (constraints as _BottomSheetBoxConstraints).keyboardInset, |
There was a problem hiding this comment.
Using a direct cast constraints as _BottomSheetBoxConstraints can lead to a runtime TypeError if the Scaffold undergoes dry layout, intrinsic height calculations, or other layout passes where the constraints might not be of the custom _BottomSheetBoxConstraints type.
Using a safe type check with is is much more robust and prevents potential crashes.
inset: constraints is _BottomSheetBoxConstraints ? constraints.keyboardInset : 0.0,
elliette
left a comment
There was a problem hiding this comment.
LGTM with one test suggestion
…board (#13244) Found while investigating flutter/flutter#179482 (design: https://flutter.dev/go/ios-26-keyboard-bleed). Companion to #13242, which does the same for `Scaffold` persistent bottom sheets. `Dialog` builds `AnimatedPadding(viewInsets)` → `Material`, so when a text field inside a `Dialog.fullscreen` is focused, the "fullscreen" surface shrinks to the area above the keyboard and the `DialogRoute` barrier is what sits behind the keyboard. On iOS 26 the keyboard is translucent, so the dimmed route underneath shows through under the dialog instead of the dialog's color. Since `Dialog.fullscreen` also removes `viewInsets` from `child`, apps can't work around it from inside the dialog. For `Dialog.fullscreen`, the `AnimatedPadding` and `MediaQuery.removeViewInsets` now sit inside the `Material`, so the surface keeps covering the whole screen while `child` is laid out above the keyboard exactly as before. Regular `Dialog`s are unchanged. Part of flutter/flutter#179482. ## Before <img width="402" alt="before: the dimmed route behind the dialog shows through the keyboard" src="https://raw.githubusercontent.com/victorsanni/packages/assets-fullscreen-dialog-keyboard/fullscreen_dialog_before.png" /> ## After <img width="402" alt="after: the dialog's surface continues behind the keyboard" src="https://raw.githubusercontent.com/victorsanni/packages/assets-fullscreen-dialog-keyboard/fullscreen_dialog_after.png" /> ## Pre-Review Checklist [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
flutter/packages@0478162...63881f9 2026-11-06 victorsanniay@gmail.com [material_ui] Paint Dialog.fullscreen background color behind the keyboard (flutter/packages#13244) 2026-11-05 kevmoo@users.noreply.github.com [material_ui] Add tabBar/tab roles and expanded state semantics (flutter/packages#13176) 2026-11-05 44747303+theprantadutta@users.noreply.github.com [material_ui] Disable the DropdownButtonFormField decoration when the field is disabled (flutter/packages#13473) 2026-11-05 mkmt@google.com [material_ui] Fix Switch throwing when first painted mid-animation (flutter/packages#13496) 2026-11-05 21270878+elliette@users.noreply.github.com [various] Add engineIdentifier to fake plugin registrars (flutter/packages#13574) 2026-11-05 60074989+arifozgun@users.noreply.github.com [google_sign_in] Allow GoogleSignIn-iOS 10 (flutter/packages#13306) 2026-11-05 11473691+YeungKC@users.noreply.github.com [material_ui] Hit test the floating label of InputDecorator at its painted position (flutter/packages#13326) 2026-11-05 mmohankrishna@google.com [material_ui] Fix InputDecorator intrinsic height when isDense or isC… (flutter/packages#13522) 2026-11-05 victorsanniay@gmail.com [material_ui] Paint Scaffold persistent bottom sheet background color behind the keyboard (flutter/packages#13242) 2026-11-05 victor.orozco@cloudsufi.com [image_picker_ios] PR 5/5 Switch Pigeon to Swift and finish the Objective-C to Swift migration. (flutter/packages#13493) If this roll has caused a breakage, revert this CL and set the roller to dry run mode using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC flutter-ecosystem@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Ports flutter/flutter#186365 to
material_ui(design: https://flutter.dev/go/ios-26-keyboard-bleed).With a persistent bottom sheet (
Scaffold.bottomSheetorScaffoldState.showBottomSheet) andresizeToAvoidBottomInset: true, the sheet is lifted above the keyboard and theScaffold's ownMaterialis what sits behind the keyboard. On iOS 26 the keyboard is translucent, so the scaffold color shows through under the sheet instead of the sheet's color._ScaffoldLayoutnow extends the persistent sheet's slot by the part of the keyboard inset not already covered by the bottom bars, while still reporting the content-only height so FAB andSnackBargeometry are unchanged._StandardBottomSheetpads its content inside theBottomSheet'sMaterialby that amount (growing the sheet's constraints to match), so the sheet's surface continues behind the keyboard.resizeToAvoidBottomInset: false,showModalBottomSheet, andBottomSheet's public API are unchanged.Fixes the framework-owned part of flutter/flutter#179482.
Before
After
Pre-Review Checklist
[shared_preferences]///).Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2